A Machine Learning Approach for the Detection of QRS Complexes in Electrocardiogram (ECG) Using Discrete Wavelet Transform (DWT) Algorithm

This study describes a modified approach for the detection of cardiac abnormalities and QRS complexes using machine learning and support vector machine (SVM) classifiers. The suggested technique overtakes prevailing approaches in terms of both sensitivity and specificity, with 0.45 percent detection error rate for cardiac irregularities. Moreover, the vector machine classifiers validated the proposed method's superiority by accurately categorising four ECG beat types: normal, LBBBs, RBBBs, and Paced beat. The technique had 96.67 percent accuracy in MLP-BP and 98.39 percent accuracy in support of vector machine classifiers. The results imply that the SVM classifier can play an important role in the analysis of cardiac abnormalities. Furthermore, the SVM classifier also categorises ECG beats using DWT characteristics collected from ECG signals.


Introduction
One of the foremost reasons of death in the world is heart disease and heart stroke. Early detection of arrhythmia situations via ECG signal analysis could improve the identification of risk factors for cardiac arrest. Baseline drifts and power line interference along with physiological abnormalities distort the ECG signal [1]. ECG signal noises can be eliminated using a variety of approaches. Mathematical morphology (MM) [2], empirical mode decomposition (EMD) [3], adaptive filtering (AF) [4], weighted averaging filter (WAF) [5], and independent component analysis (ICA) [6] are some of the most commonly used methods. Electromyography (EMG) noise can be eliminated by using adaptive wavelet wiener filtering of ECG signals [7]. e characteristics of an ECG signal can be analysed statistically [8] and retrieved in time and frequency domains [9,10]. An accurate reading of the QRS complex is essential to ECG analysis because it contains the majority of the heart's electrical action [11]. Preprocessing techniques such as filtering and smoothing are used to reduce P and T waves and noise [12]. e uncovering of the QRS onset and offset facts, which begin with the R-peaks, is the first step in computing the QRS duration. ECG signal analysis can be improved by locating the correct fiducial point [13,14]. Digital filters and nonlinear transforms are utilised to excerpt the feature constituents of the QRS signal [15,16]. e modulus maxima were found using a multiscale QRS indicator employing discrete wavelet transform (DWT).
ere are numerous signal processing applications that use the DWT algorithm. Constants that indicate the adequate evidence of the real data are used to divide DWT signals into different coarseness levels [17,18] [19][20][21]. Using WT's multiscale feature, it is possible to detect the QRS complex and P wave and T waves with 99.5% accuracy even in the occurrence of baseline drift and noise. Martinez et al. [18,22] proposed a dyadic wavelet-based method for locating the maximum positive and minimum negative peaks. To evaluate the ECG signal's QRS complex, P wave, and T waves, a multiresolution wavelet transform system with optimal coefficients was applied. ere is 99.9% accurate recognition rate for R-peak and a base accurateness of 97.6%, 96.65%, and 98.85% of heart rate for P wave, T wave, and QRS complex correspondingly, in these measurements [21]. Rescaled wavelet coefficients were utilised to enhance the QRS complex and lessen its impact on other peaks [23]. QRS can be detected with a classification based on morphology that has a 99.91 percent average sensitivity and a 99.72 percent positive predictivity [24]. When used with adaptive thresholding to detect the peaks and waves of ECG signals, multiresolution WT showed 99.8 percent sensitivity and positive predictivity in the MIT-BIH arrhythmia database and 99.84 percent in the PTB database [25]. e deconstructed signals' power spectra were utilised to generate a multiresolution wavelet transform, which was then used to determine detail coefficients for the QRS complex's parameters 1 and 2 [26]. An error rate of 0.34 percent was found in the evaluation, which exhibits the best detection performance with 99.87 percent global sensitivity and 99.79 percent positive predictivity [26]. Wavelet coefficients and wavelet coefficient energy were used for detection in the real-time QRS complex detector developed by Junior et al. [22] in 2016. e algorithm's detection rate for QRS complexes was 99.32 percent. e identification and classification of cardiac arrhythmias are the primary goals of this study. e classification of cardiac arrhythmia has been the subject of much debate in the medical literature. SVMs (support vector machines) [27] and ANNs (artificial neural networks) [28] are two such approaches. Profligate and precise categorization of cardiac rhythms has been achieved using an OPF classifier based on supervised graph pattern recognition [29].
Pathological situations alter ECG morphologies; therefore, designing a robust algorithm to accurately detect QRS complexes is a challenge [11]. e multiresolution wavelet transform and amplitude thresholding are used in this study to offer an upgraded approach for detecting QRS complex structure and R-peaks. Neural networks and support vector machines (SVM) were used to identify four cardiac abnormalities: normal (N), left bundle branch block (LBBB) and right bundle branch block (RBBB), and paced beats (P) [30]. An ECG database of 48 documented ECG data from MIT-BIH arrhythmias was used to estimate the enactment of the proposed procedure for sensitivity, specificity, and accuracy as the parameter.
Motivation: QRS complex is the most notable feature and can be used to extract further clinical information from ECG signals, such as RR interval, QT interval, and PR interval, among other things [2]. Detecting QRS on an ECG is, therefore, essential for health assessment based on the ECG. e discrete wavelet transform (DWT) techniques are well established in signal processing across a wide range of scientific and industrial fields [7]. DWT is regularly employed to answer and cure more complex problems since it gives both octave-scale frequency and spatial time of the investigated signal.

QRS Detection Approaches
MATLAB was used to transform the ECG signals from the MIT-BIH arrhythmia database, which had sampling frequency, set to 360 Hz (.mat). A 10 mV range of 11 bit resolution ECG signals is used to store 48 recordings of 30 minute duration each. Figure 1 shows a block diagram of the proposed algorithm for detecting the QRS complex in ECG signals [31]. Denoising, QRS detection, R-peak identification, on and off peaks, and morphological parameter extraction are all part of this process. It was evaluated on the first channel's ECG signals using MATLAB 2018 version of the technique. Approximately 1.33 seconds of each 30 minute ECG dataset was required for processing [32].

Discrete Wavelet Transform (DWT).
e Fast Fourier Transform (FFT) is an important tool for signal processing applications that analyse stationary signals. A nonstationary signal does not match the performance requirements of this device [33]. While you are seeking for a means to analyse temporal frequency, you can utilize the short time Fourier transform (STFT). Time frequency resolution is the primary challenge with STFT. STFT's disadvantage can be rectified by employing the wavelet transform, which provides good temporal and frequency resolution. Using the wavelet transform to evaluate nonstationary signals such as ECG is an efficient method because of its ability to localise time and frequency [34]. Biomedical signal processing makes extensive use of DWT because of its lower computational complexity than that of FFT. ECG signal decomposition is also used to remove noise and enhance ECG signal components by scaling the ECG signal. An w(t) signal's wavelet transform is defined by Complex conjugate of wavelet transform φ * (t) and dilation and location parameters of the wavelet, respectively, are d and l in this equation. e orthonormal wavelet basis function is used in DWT's dyadic grid. If you use a discretized grid, such as the d-l grid, to calculate the transform integral, you will get the same result. One way to express the DWT function is as follows [35]: Dilation and translation are denoted by m and n, respectively. e default settings for the dilation (p > 1) and location (q > 0) parameters are m and b, respectively.

Computational Intelligence and Neuroscience
When trying to identify the QRS complex in an ECG waveform, wavelet selection is critical. ere is no way to select a wavelet that is accurate [35]. e wavelet is chosen based on the information included in the processed signal. e following wavelets are readily available: Daubuchies, Haar, Biorthogonal, Symlets, Morlets, Mexican Hats, Mayers, and Coiflets.

Preprocessing.
e most crucial component in signal decomposition is to select a wavelet type that closely counterparts the morphology of the data under deliberation [36]. To enhance the QRS complex shape, noninformative frequency constituents were decomposed with multiresolution wavelet transform utilising db6 in the preprocessing step. To improve the signal, noise with equivalent detail coefficients at D1, D2, and A10 is removed from the high frequency ranges at D1 and D2.

Detection of R-Peaks
. R-wave locations are defined by the denoised ECG signal's greatest amplitude. Figure 2 depicts the detection process for Rloc. In order to locate the window of 160 ms around the QRS area, a pragmatic verge of 15% of the maximal amplitude addition of D3, D4, and D5 was carefully determined. To find amplitudes greater than the predefined edge level, the ECG beats are denoised. A signal's R-peak placements are determined by its highest amplitude [35]. Ventricular depolarization cannot be detected during the refractory period, which is 200 ms. In an array of Rloc, the identified supreme peaks are kept as "Rpeaks."

Classification Methods
We have studied various classification methods. Few of them are mentioned below.

Multilayer Perceptron Neural Network (MLP).
In ECG signal investigation, the neural network classifier is the most commonly utilised [1]. e neural network topology known as "multilayer perception" (or "MLP") is widely used. Using the backpropagation algorithm, MLPs are trained by allowing mistakes to circulate over the network and allowing adaption of the secreted nodes [37]. Simply stated, its function is where A i is input as A � [a 1 , a 2 . . . . . . a n ] T and X ij are set of weights X � [x 1 , x 2 . . . . . . x n ] T . Moreover, error can be calculated as When learning with gradient descent, the input and error values at each weight in the network are corrected, i.e., Figure 3 depicts the investigational design of MLP, which is created with eight input topographies in the input layer, one secreted layer, and four modules in the output layers to categorise ECG rhythms.

Support Vector Machine (SVM).
is very nonlinear network topology uses the notion of structural risk minimization to accurately classify previously unknown patterns [38]. Support vector machines lower structural risk, whereas empirical risk has increased. SVM maximises the expanse between the configurations and the hyperplane. It optimises the class separation boundary in order to keep the distance between a feature and a class 29 separating hyperplane at its largest simultaneous value. Kernels for training include quadratic, polynomial, and radial basis functions [23].   Computational Intelligence and Neuroscience e fiducial point interludes of an ECG in a cardiac sequence are used to classify an ECG signal automatically. Each heartbeat had its own set of intervals and ECG morphological traits. Table 1 lists the characteristics of a single cardiac cycle. In Figure 4, the ECG classification approaches are depicted as a block diagram. Using the ECG preprocessed signal, the proposed classification technique extracts temporal, R-R interval, and morphological information [2]. e NN classifier uses a combination of variables to categorise various cardiac problems (Paced beats, Normal, RBBBs, and LBBBs).

Evaluation Measure and Results
Filters are employed in a different ways, liable on the explicit application. In order to pick the best technique and develop new methodologies, performance measures are used [9]. Metrics such as accuracy, signal-to-noise ratio (SNR), mean square error (MSE), specificity, and sensitivity are deliberated by comparing the enactment of prevailing and new methods.

Accuracy.
Metrics count the number of times a forecast was correct out of all the possible outcomes: where for TP : True Positive, correct value is detected as correct, for TN : True Negative, incorrect value is detected as correct, for FP : False Positive, correct value is detected as incorrect, and for FN : False Negative, incorrect value is detected as incorrect.

Sensitivity.
Measure the percentage of positive patterns which is accurately categorised. e percentage of incorrectly categorised negative patterns is what we refer to as sensitivity: TP and FN are mentioned in equation (7).

Specificity.
e difference between the projected and desired solutions is what we mean by "specificity:" TN, TP, and FP are mentioned in equation (8).

Positive Predictability (+P).
e algorithm's ability to distinguish between real and fake beats is evaluated using positive predictability:

Results and Discussion
e MIT-BIH arrhythmia database was applied to test the suggested R-peak and QRS complex recognition methods. Excellence, waves, QRS complex, and uneven cardiac beats of the recorded ECG signals are all within acceptable limits. Figure 5 to Figure 7 after a wavelet transform and baseline wander correction. Table 2 summarises the consequences of all 24 accounts in the MIT-BIH arrhythmia database, which are shown in Figure 8 as simulations of R-peak detection.

Onset and Offset Recognition of ECG Peaks.
e QRS complex can be found once the R-peak and Q and S points have been located exactly [25]. In order to locate the Q-peak (Qloc), 30 samples are examined for a negative maximum on the leftward side of the fiducial point (Rloc). Fifty samples are selected from the right-side fiducial area in order to indicate Sloc. Figure 9 and 10 show the minimum slopes for the Q and S positions, which are kept in a collection of Q-index and S-index. An examination is launched by picking 20 samples to the leftward of Qloc and to the rightward of Sloc. An Rloc range of 30 to 160 was selected for the T-peak localization, and the largest value within this range is considered Tloc.
irty five and fifty samples are selected in a search procedure, which is a standard sample set for a regular T wave duration. Tloc's absolute minima on either side are depicted in Figure 11 as T On and T Off, respectively.

Conclusion
Methods for extracting features from the multiresolution wavelet transform (MLP-BP) and categorising for cardiac irregularities by machine learning (SVM) are presented in this study. rough a recognition fault rate of 0.45 percent, the suggested method outperforms existing methods in the recognition of QRS complexes in terms of specificity and sensitivity, compared to previously published data. In terms of classification accuracy, the classifiers agreed that our proposed strategy was preferable for categorising four different types of ECG rhythms: LBBBs, Normal, RBBBs, and Paced beats. In the classifiers, such as MLP-BP and support vector machine, the method attained a mediocre classification accuracy of 96.57 and 98.59 percent, respectively. Support vector machine (SVM) classifiers may play a noteworthy part in the clarification of information in the identification of heart issues. According to the findings of this study, categorising ECG rhythms using DWT-based topographies collected from ECG data was found to be feasible using the SVM classifier. We found that the SVM classifier can categorise ECG beats [39] using DWT characteristics taken from ECG signals.
In future, we will try to design a method which will applicable for real-time data. Moreover, the method will be applicable on big data too.
Data Availability e data that support the findings of this study are available on request from the corresponding author.

Conflicts of Interest
e authors declare that they have no conflicts of interest.  Computational Intelligence and Neuroscience 7